<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 查找字符串"abcoefoxyozzopp"中所有o出现的位置以及次数
        var str = "abcoefoxyozzopp";
        var loc = str.indexOf('o');
        var num = 0;
        while (loc != -1) {
            console.log(loc);
            num++;
            loc = str.indexOf('o', loc + 1);
        }
    </script>
</head>

<body>

</body>

</html>